package query

import (
	"ssforward/common/dto"
)

type ForwardRuleQuery struct {
	dto.Pagination `search:"-"`
	dto.OrderBy    `search:"-"`
	dto.UserInfo
	Id           string `form:"id" json:"id" search:"type:exact;column:id;table:sys_forward_rule"`
	Name         string `form:"name" search:"type:contains;column:name;table:sys_forward_rule"`
	ProductModel string `form:"productModel" search:"type:contains;column:product_model;table:sys_forward_rule"`
	DevSn        string `form:"devSn" search:"type:contains;column:dev_sn;table:sys_forward_rule"`
	ServerType   string `form:"serverType" search:"type:exact;column:server_type;table:sys_forward_rule"`

	AgencyIdEq string   `search:"type:exact;column:agency_id;table:sys_forward_rule"`
	IdIn       []string `search:"type:in;column:id;table:sys_forward_rule"`
	ServerIdIn []string `search:"type:in;column:server_id;table:sys_forward_rule"`
}

func (m *ForwardRuleQuery) GetNeedSearch() interface{} {
	if m.UserId != "1" {
		m.AgencyIdEq = m.AgencyId
	}
	return *m
}
